package io.renren.modules.api.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.api.interceptor.AuthorizationInterceptor;
import io.renren.modules.footprint.entity.VipfootprintinfosCustomEntity;
import io.renren.modules.footprint.service.VipfootprintinfosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @program: stf
 * @description: 足迹
 * @author: Custom
 * @create: 2018-11-02 14:43
 **/
@RestController
@RequestMapping("/api/footprint")
public class ApiFootprintController {

    @Autowired
    private VipfootprintinfosService vipfootprintinfosService;

    //获取收藏列表
    @GetMapping("/list")
    public R submitFeedback(@RequestParam Map<String, Object> params, HttpServletRequest request){
        //获取用户
        String userinfoid = (String) request.getAttribute(AuthorizationInterceptor.USER_KEY);
        params.put("userinfoid",userinfoid);
        //查询列表数据
        Query query = new Query(params);
        List<VipfootprintinfosCustomEntity> vipfootprintinfosCustomEntities = vipfootprintinfosService.queryApiList(query);
        int total = vipfootprintinfosService.queryApiTotal(query);
        PageUtils pageUtil = new PageUtils(vipfootprintinfosCustomEntities, total, query.getLimit(), query.getPage());
        return R.ok().put("page", pageUtil);
    }

}
